/*
 * =====================================================================================
 *
 *       Filename:  Message.h
 *
 *    Description:
 *
 *        Version:  1.0
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Fang Dongheng (fndisme), fndisme@163.com
 *   Organization:
 *
 * =====================================================================================
 */
#ifndef FND_MESSAGE_H
#define FND_MESSAGE_H
#include <string>
#include <vector>
#include "base/Header.pb.h"
namespace FakeWeiXin {
using Buffer = std::vector<char>;
class Message {
 private:
  Prototal::Header m_header;
  std::string m_body;

 public:
	void swap(Message& msg);
  Buffer toBuffer() const;
	void debugPrint() const;
  static constexpr std::size_t headerSize() { return 10; }
  void fillMessage(int type, std::string&& msg) {
    m_body = std::move(msg);
    m_header.set_size(m_body.size());
    m_header.set_type(type);
  }
	static bool buildFromBuffer(const Buffer& buf, Message* msg);
};
}
#endif

